package com.store.bookstore_backend.web.controller;

import com.store.bookstore_backend.dto.APIResponse;
import com.store.bookstore_backend.dto.CollectGetDTO;
import com.store.bookstore_backend.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@RestController
public class CollectController {
    @Autowired
    CollectService collectService;
    @GetMapping("/collect/")
    public APIResponse<List<CollectGetDTO>> collect(HttpServletRequest request) {
        return APIResponse.success(collectService.getCollectList(request));
    }
    @PostMapping("/collect/{id}")
    public APIResponse<Object> collect(@PathVariable Integer id, HttpServletRequest request) {
        collectService.insertCollect(id, request);
        return APIResponse.success();
    }
    @DeleteMapping("/collect/")
    public APIResponse<Object> delete(@RequestBody List<Integer> Ids) {
        collectService.DeleteCollect(Ids);
        return APIResponse.success();
    }
}
